package com.example.demo_spring;

import com.example.demo_spring.ioc_di.controller.HelloController;
import com.example.demo_spring.ioc_di.spring.Hello;
import com.example.demo_spring.ioc_di.spring.depInterface.MyHello;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

@SpringBootApplication
public class DemoSpringApplication {

    public static void main(String[] args) {
//        SpringApplication.run(DemoSpringApplication.class, args);
        ConfigurableApplicationContext context =
                SpringApplication.run(DemoSpringApplication.class, args);
        System.out.println("SpringApplication.run done!");

        // 模拟Spring MVC 收到前端浏览器发起请求，调用HelloController 的hello 函数
//        HelloController hc = (HelloController) context.getBean("helloController");
//        hc.hello();

        Hello h = (Hello) context.getBean("hello");
        h.toCustomer();
//

//        MyHello mh = (MyHello) context.getBean("myHello");
//        mh.toCustomer();
    }

}
